local dianchi = fk.CreateSkill{
  name = "xiaobai__dianchi",
  tags = {Skill.Switch}
}
dianchi:addEffect(fk.HpChanged,{
  anim_type = "switch",
  switch_skill_name = "xiaobai__dianchi",
  events = {fk.HpChanged},
  can_trigger = function(self, event, target, player, data)
    if not (target == player and player:hasSkill(dianchi.name)) then return end
    if player:getSwitchSkillState(dianchi.name, false) == fk.SwitchYang then
      if player.hp == 1 then
        return true
      end
    else
      if data.num > 0 and player.hp == player.maxHp then
        return true
      end
    end
  end,
  
  on_use = function(self, event, target, player, data)
    local room = player.room
    local handcardNum = #player:getCardIds("h")
    if handcardNum < 4 then
      room:drawCards(player, 4 - handcardNum, dianchi.name)
    end
  end,
})

Fk:loadTranslationTable{
  ["xiaobai__dianchi"] = "点赤",
  [":xiaobai__dianchi"] = "转换技，阳：当你的体力变化为1后；阴：当你回复体力至上限后，你将手牌摸至四张。",

  [":xiaobai__dianchi_yang"] = "转换技，<font color=\"#E0DB2F\">阳：当你的体力变化为1后；</font>阴：当你回复体力至上限后，你将手牌摸至四张。",
  [":xiaobai__dianchi_yin"] = "转换技，阳：当你的体力变化为1后；<font color=\"#E0DB2F\">阴：当你回复体力至上限后，你将手牌摸至四张。</font>",
}

return dianchi